package com.zh.streamdemo.demo1;

import java.util.Optional;
import java.util.stream.Stream;

public class DemoFind {

    public static void main(String[] args) throws InterruptedException {
        Optional<String> first = Stream.of("地瓜", "土豆", "茄子", "白菜", "土豆", "茄子", "黄瓜").findFirst();
        System.out.println(first.get());
        for (int i = 0; i < 50; i++) {
            new Thread(() -> {
                Optional<String> any = Stream.of("地瓜", "土豆", "茄子", "白菜", "土豆", "茄子", "黄瓜").findAny();
                System.out.println(any.get());
            }).start();
        }
    }
}
